Skip to content

Conversation

@theihor
Copy link
Contributor

@theihor theihor commented Oct 15, 2025

pyrefly [1] is a modern type checker, suggested as a successor of
pyre-check [2].

Add pyrefly configuration to pyproject.toml
Add pyrefly check run in main ci workflow.

Following the recommendation from the docs, annotate existing errors
detected by pyrefly [3]. We'll be removing them incrementally with new
code changes.

[1] https://github.com/facebook/pyrefly
[2] https://github.com/facebook/pyre-check
[3] https://pyrefly.org/en/docs/error-suppressions/#upgrading-pyrefly-and-other-changes-that-introduce-new-type-errors

Internal Meta typechecker reported a couple of issues in recent PR
comments forwardning feature [1].

Fix them with additional checks and local variables.

[1] #25

Signed-off-by: Ihor Solodrai <[email protected]>
pyrefly [1] is a modern type checker, suggested as a successor of
pyre-check [2].

Add pyrefly configuration to pyproject.toml
Add pyrefly check run in main ci workflow.

Following the recommendation from the docs, annotate existing errors
detected by pyrefly [3]. We'll be removing them incrementally with new
code changes.

[1] https://github.com/facebook/pyrefly
[2] https://github.com/facebook/pyre-check
[3] https://pyrefly.org/en/docs/error-suppressions/#upgrading-pyrefly-and-other-changes-that-introduce-new-type-errors

Signed-off-by: Ihor Solodrai <[email protected]>
Copy link

@danielocfb danielocfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for taking this on.

"""
tos = msg.get_all("To", [])
ccs = msg.get_all("Cc", [])
# pyrefly: ignore # implicit-import

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the # implicit-import bit carry any semantics for the checker? I was under the impression the syntax would be

# pyrefly: ignore[implicit-import]

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotations were generated by pyrefly command, so I guess that's the expected syntax.

self._add_ci_files()

try:
# pyrefly: ignore # missing-attribute

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of shocking how many additional suppressions we need. Just curious, have you investigated why that is? Are the git bindings so bad, somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't investigated in detail. My impression is that the type checker is quite defensive, while KPD codebase isn't rich enough with the type annotations.

This self.repo_local is set to None in constructor without an annotation, and then overwritten in fetch_repo_branch. I'm pretty sure pyrefly can't see that.

Similarly, it seems to not understand mocks, for example

m = MagicMock()
# pyrefly: ignore # missing-attribute
m.__str__.return_value = remote_ref

Hopefully, we'll clean it up bit by bit.

@theihor theihor merged commit b49cb95 into main Oct 16, 2025
5 checks passed
@theihor theihor deleted the typecheck branch October 16, 2025 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants